varying vec2 aCoordinate;
uniform sampler2D inputImageTexture;
uniform int vYcount;

vec4 spiltY(vec2 uv){
    vec4 color;
    if (vYcount == 1){
        color = texture2D(inputImageTexture, uv);
    } else if (vYcount == 2){
        float yf = float(vYcount);
        float pre = 1.0/yf;
        if (uv.y >= 0.0 && uv.y <= pre){
            float uy = uv.y + pre/yf;
            vec2 coordinate = vec2(uv.x, uy);
            color = texture2D(inputImageTexture, coordinate);
        } else {
            vec2 coordinate = vec2(uv.x, uv.y - pre/yf);
            color = texture2D(inputImageTexture, coordinate);
        }
    } else {
        if (uv.y >= 0.0 && uv.y <= 0.33) { // 上层
            vec2 coordinate = vec2(uv.x, uv.y + 0.33);
            color = texture2D(inputImageTexture, coordinate);
        } else if (uv.y > 0.33 && uv.y <= 0.67) { // 中间层
            color = texture2D(inputImageTexture, uv);
        } else { // 下层
            vec2 coordinate = vec2(uv.x, uv.y - 0.33);
            color = texture2D(inputImageTexture, coordinate);
        }
    }
    return color;
}

void main()
{
    highp vec2 uv = aCoordinate;
    gl_FragColor = spiltY(uv);;
}

